<?php
ob_start();
if(isset($_SERVER['HTTP_APPVERSION'])){
include "./saesiteinfo.php";
}else{
 if(!file_exists("./install/install.lock")){
header('location:./install');
exit;
 }else{
include "./siteinfo.php";
 }
}
//连接数据库
$localhost=mysql_connect($sqlhost,$sqluser,$sqlpass)or die("无法连接服务器");
mysql_select_db($sqldata,$localhost);
?>
<html>
<head>
<meta content="width=device-width,user-scalable=no" name="viewport">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>密码找回 - <?php echo $sitename; ?></title>
<link rel="stylesheet" type="text/css" href="css/register.css"/>
</head>
<body>
<div class='signup_container'>
    <h1 class='signup_title'>密码找回</h1>
                <div id="signup_forms" class="signup_forms clearfix">
<?php if(empty($_POST['submit']))
{
?>
<center>
<form class="signup_form_form" action="" method="post" >
                    <div class="form_row">
                        <label for="signup_password">请输入用户名</label>
                        <input type="text" name="user" placeholder="请输入用户名" id="signup_user" data-required="required">
                    </div>
              <div class="form_row">
                        <label for="signup_password">联系邮箱</label>
                <input type="text" name="email" placeholder="联系邮箱" id="signup_email" data-required="required">
                    </div>
			              <div class="form_row">
                        <label for="signup_password">新密码</label>
                <input type="password" name="xinpass" placeholder="新密码" id="signup_email" data-required="required">
                    </div>
</div>

    <div class="login-btn-set"><div class='rem'>确定找回</div> <input type="submit" value=" " name="submit" class='login-btn1'></form></div>
</form>
</center>
<?php
}
else
{
$user=$_POST["user"];
$email=$_POST['email'];
$xinpass=$_POST["xinpass"];
$mysql = mysql_query("SELECT * FROM user WHERE user='$user'");
$ziliao= mysql_fetch_array($mysql);
if ($user=="")
{
echo '<center>用户账户不能为空!</center>';
}
elseif ($email=="")
{
echo '<center>联系邮箱不能为空!</center>';
}
elseif ($xinpass=="")
{
echo '<center>新密码不能为空!</center>';
}
elseif ($email!=$ziliao['email'])
{
echo '<center>用户账户的联系邮箱不是这个!</center>';
}
else
{
$pass=md5($xinpass);
mysql_query("UPDATE user SET pass= '$pass' WHERE user='$user'");
echo "<center>密码找回成功<br />您的密码是刚刚更改的新密码，请<font color=red>妥善保存</font></center>";
}
}

?></td>
  </tr>
  <tr>
    <td height="28"><div align="center"><a href="index.php">返回首页</a>|<a href="javascript:history.back(-1)">返回上页</a></div></td>
  </tr>
</table>
</body>
</html>